n, m, k = map(int, input().split())
mines = [list(map(int, input().split())) for i in range(k)]
List = []
count = 0

for i in range(len(mines)):
    for j in range(len(mines[i])):
        mines[i][j] -= 1

for i in range(n):
    List.append(list())
    for j in range(m):
        List[i].append(".")

for i in range(k):
    List[mines[i][0]][mines[i][1]] = "*"

for i in range(n):
    for j in range(m):
        if List[i][j] != "*":
            try:
                if List[i+1][j+1] == "*":
                    count += 1
                if List[i+1][j] == "*":
                    count += 1
                if List[i][j+1] == "*":
                    count += 1
                if List[i - 1][j] == "*":
                    count += 1
                if List[i][j - 1] == "*":
                    count += 1
                if List[i - 1][j - 1] == "*":
                    count += 1
                if List[i - 1][j + 1] == "*":
                    count += 1
                if List[i + 1][j - 1] == "*":
                    count += 1
                if count != 0:
                    List[i][j] = count
                count = 0
            except IndexError:
                continue
for i in range(len(List)):
    print(" ".join(map(str, List[i])))

